#!/bin/bash
cd `dirname $0`
now=$(date +%Y%m%d)
jar_name=
current_dir=$(cd `dirname $0`; pwd)
for jar_name in `ls .|egrep '*.jar|*.war'`
do
   if [ -n "$jar_name" ]; then
      echo "find  $jar_name"
   fi
   break

done

if [ "$jar_name" = "" ]; then
   echo "not find *.jar or *.war"
   exit 11
fi


echo "start $jar_name"
pid=`ps -ef | grep "\-\-pwd=${current_dir}/${jar_name}" | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]
then
   echo "kill pid $pid"
  kill -9 $pid
fi

nohup /usr/java/jdk-11.0.7/bin/java -jar -Xms750m -Xmx750m -XX:MaxMetaspaceSize=178m -XX:MetaspaceSize=178m -Xss512k  -Dlog4j2.formatMsgNoLookups=true -Dspring.cloud.bootstrap.enabled=true  -Dloader.path=lib -Dserver.tongweb.license.type=file -Dserver.tongweb.license.path=/opt/tongWEB/license.dat -jar  ./${jar_name} --spring.main.allow-bean-definition-overriding=true --spring.profiles.active=dev,nacos --spring.main.allow-circular-references=true --pwd=${current_dir}/${jar_name} --app.group=default --app.product-line.code=lzapp >${jar_name}.log 2>&1 &

tail -f ${jar_name}.log

 trap "ps -aux |grep ${jar_name}|awk '{print $2 "    ----    " $22}'" HUP INT QUIT TSTP

ps -aux |grep ${jar_name}|awk '{print $2 "    ----    " $22}'
